//
//  FFTools.h
//  Common
//
//  Created by IT.Bear on 16/5/20.
//  Copyright (c) 2016年 Fashionfinger. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface FFTools : NSObject


/**
 UIView深拷贝

 @param view 要copy的UIView

 @return 
 */
+ (UIView*)duplicate:(UIView*)view;
//label 竖向
+(CGFloat)imageHeight:(NSString *)imageUrl;
//去除float多余的0
+(NSString*)removeFloatAllZero:(NSString*)string;
+ (NSString *)verticalString:(NSString *)content;
+ (NSString *)getWeek:(NSDate *)date;
+ (NSString *)dataToJsonString:(id)object;
+ (NSString *)contentTypeForImageData:(NSData *)data;
+ (UIImage *)makeImageWithView:(UIView *)view;
+ (NSString *)getTimesp;
//+ (UINavigationController *)currentNavigation;
+ (BOOL)checkStringIsBlank:(NSString*)str;
+ (NSArray *)IsContainChinese:(NSString *)str;//是否有中文  有=yes

+ (NSDateFormatter*)dateFormatter;

+ (NSString*)timeToString:(double)unixtime Format:(NSString*)formatStr;

// 将JSON串转化为字典或者数组
+ (id)toArrayOrNSDictionary:(NSString *)urlStr;
//判断字符串是否全是空格
+ (BOOL)isEmpty:(NSString *)str ;
+ (NSDictionary *)jsonStringToDic:(NSString *)jsonString;
/**
 *  unicode 转 utf-8
 *
 *  @param aUnicodeString
 *
 *  @return 
 */
+ (NSString*)replaceUnicode:(NSString*)aUnicodeString;

/**
 生成颜色图片

 @param color
 @return
 */
+ (UIImage *)imageWithColor:(UIColor *)color;
/**
 *  是不是字母开头
 *
 *  @param str
 *
 *  @return
 */
+(BOOL)MatchLetter:(NSString *)str;
/**
 *  互联网 App 中经常会用到 html 颜色值转换 UIColor，比如：#FF9900、0XFF9900 等颜色字符串，以下方法可以将这些字符串转换为 UIColor 对象
 *
 *  @param color 颜色字符串
 *
 *  @return 返回color对象
 */
+ (UIColor *) colorWithHexString: (NSString *)color;

/**
 *  检测是否中文
 *
 *  @param str <#str description#>
 *
 *  @return <#return value description#>
 */
+ (BOOL)validateChinese:(NSString *)str;

/**
 *  检测是否身份证
 *
 *  @param identityCard identityCard descriptio
 *
 *  @return
 */
+ (BOOL)validateIdentityCard:(NSString *)identityCard;


/**
 *  随机颜色
 *
 *  @return <#return value description#>
 */
+ (UIColor *)randomColor;

/**
 *  cell上的组件得到cell
 *
 *  @param obj 组件
 *
 *  @return UITableViewCell
 */
+ (UITableViewCell *)tableViewCell:(id)obj;

/**
 *  生成图片
 *
 *  @param color  图片颜色
 *  @param height 图片高度
 *
 *  @return 生成的图片
 */
+ (UIImage*) GetImageWithColor:(UIColor*)color andSize:(CGSize)size;

/**
 *  拨打电话
 *
 *  @param phoneNumber <#phoneNumber description#>
 */
//+ (void)callPhone:(NSString*)phoneNumber;


/**
 *  字符串转NSDate
 *
 *  @param theTime 字符串时间
 *  @param format  转化格式 如yyyy-MM-dd HH:mm:ss,即2015-07-15 15:00:00
 *
 *  @return <#return value description#>
 */
+ (NSDate *)dateFromString:(NSString *)timeStr
                    format:(NSString *)format;

/**
 *  NSDate转时间戳
 *
 *  @param date 字符串时间
 *
 *  @return 返回时间戳
 */
+ (NSInteger)cTimestampFromDate:(NSDate *)date;

/**
 *  字符串转时间戳
 *
 *  @param theTime 字符串时间
 *  @param format  转化格式 如yyyy-MM-dd HH:mm:ss,即2015-07-15 15:00:00
 *
 *  @return 返回时间戳的字符串
 */
+(NSInteger)cTimestampFromString:(NSString *)timeStr
                          format:(NSString *)format;


/**
 *  时间戳转字符串
 *
 *  @param timeStamp 时间戳
 *  @param format    转化格式 如yyyy-MM-dd HH:mm:ss,即2015-07-15 15:00:00
 *
 *  @return 返回字符串格式时间
 */
+ (NSString *)dateStrFromCstampTime:(NSInteger)timeStamp
                     withDateFormat:(NSString *)format;

/**
 *  时间戳时间字符串
 *
 *  @param timeStamp 时间戳
 *
 *  @return 返回字符串格式时间
 */
+ (NSString *)getTimeWithTimeStamp:(long long)timeStamp;

/**
 *  NSDate转字符串
 *
 *  @param date   NSDate时间
 *  @param format 转化格式 如yyyy-MM-dd HH:mm:ss,即2015-07-15 15:00:00
 *
 *  @return 返回字符串格式时间
 */
+ (NSString *)datestrFromDate:(NSDate *)date
               withDateFormat:(NSString *)format;
@end


@interface UIImage (CS_Extensions)
- (UIImage *)imageAtRect:(CGRect)rect;
- (UIImage *)imageByScalingToSize:(CGSize)targetSize;
- (UIImage*)reSizeImage:(CGSize)maxSize;
@end

@interface UIButton (ExtentionButton)
+ (UIButton*)buttonWithMyImage:(NSString*)imageName;
+ (UIButton*)buttonWithMyImage:(NSString*)imageName stretchInset:(UIEdgeInsets)inset;
+ (UIButton*)buttonWithMyImage:(NSString *)imageName Frame:(CGRect)rect;

+ (UIButton*)buttonWithTitle:(NSString*)title color:(UIColor*)_color;
+ (UIButton*)buttonWithTitle:(NSString*)title color:(UIColor*)_color rect:(CGRect)_rect;
@end

@interface UIImageView(ExtentionImageView)
+ (UIImageView*) imageViewWithMyImage:(NSString*)imageName;
+ (UIImageView*) imageViewWithMyImage:(NSString*)imageName stretchInset:(UIEdgeInsets)inset;
@end

@interface UITextField(ExtentionTextField)
- (void)setLeftMargin:(float)width;
@end

//超级容错
@interface NSObject (SuperFaultTolerant)

/**
 *  返回数组指定索引位置的元素
 *  eg:ARRAY_OBJ_AT(1)
 *  @return obj
 */
- (id)ARRAY_OBJ_AT;

/**
 *  尾部追加一个元素
 *  eg:ARRAY_ADD_OBJ(@@"name")
 */
- (void)ARRAY_ADD_OBJ;

/**
 *  尾部追加一个数组
 *  eg:ARRAY_ADD_OBJS_FROM_ARRAY(NSArray)
 */
- (void)ARRAY_ADD_OBJS_FROM_ARRAY;

/**
 *  在指定索引处插入一个元素
 *  eg:ARRAY_INSERT_OBJ_AT(@@"name",1)
 */
- (void)ARRAY_INSERT_OBJ_AT;

/**
 *  删除对应索引位置的元素
 *  eg:ARRAY_REMOVEOBJ_AT(1)
 */
- (void)ARRAY_REMOVEOBJ_AT;

/**
 *  删除对应元素
 *  eg :ARRAY_REMOVE_OBJ(@@"name")
 */
- (void)ARRAY_REMOVE_OBJ;


/**
 *  通过key查找对应的value
 *  eg:DICT_OBJ_FOR_K(@@"name")
 *  @return obj
 */
- (id)DICT_OBJ_FOR_K;

/**
 *  赋值替换键值对
 *  eg:DICT_SET_VK(@@"小黑",@@"name")
 */
- (void)DICT_SET_VK;

/**
 *  删除指定key的键值对
 *  eg:DICT_REMOVEOBJ_K(@@"name")
 */
- (void)DICT_REMOVEOBJ_K;

/**
 *  等效于先removeAllObjects后addObjectsFromArray
 *  eg:DICT_SET_DICT(NSDictionary)
 */
- (void)DICT_SET_DICT;

/**
 *  是否存在key对应的值
 *  eg:DICT_HAS_K(@@"name")
 *  @return 布尔值
 */
- (BOOL)DICT_HAS_K;

/**
 *  删除指定key数组对应的键值对
 *  DICT_REMOVEOBJS_KS(NSArray)
 */
- (void)DICT_REMOVEOBJS_KS;

-(void)My_removeObjectAtIndex:(NSInteger)index File:(char*)file Line:(int)line; //NSMutableArray
-(void)My_removeAllObjects_File:(char*)file Line:(int)line; //NSMutableArray
-(void)My_removeObject:(id)obj File:(char*)file Line:(int)line; //NSMutableArray
-(NSString*)MY_joinByString:(NSString*)sep File:(char*)file Line:(int)line; //NSArray

-(id)My_objectAtIndex:(NSInteger)index File:(char*)file Line:(int)line; //NSArray
-(void)My_setObject:(id)value forKey:(id)key File:(char*)file Line:(int)line; //NSMutableDictionary
-(void)My_setDict:(NSDictionary*)dict File:(char*)file Line:(int)line; //NSMutableDictionary
-(void)My_removeObjectForKey:(id)key File:(char*)file Line:(int)line;
-(void)My_removeObjectsForKeys:(NSArray*)keys File:(char*)file Line:(int)line;
-(BOOL)My_hasKey:(id)key File:(char*)file Line:(int)line;//NSDictionary

- (int)My_count_File:(char*)file Line:(int)line;
- (id)My_objectForKey:(id)aKey File:(char*)file Line:(int)line;
- (NSArray *)My_allKeys_File:(char*)file Line:(int)line;
- (NSArray *)My_allValues_File:(char*)file Line:(int)line;
- (void)My_addObject:(id)anObject File:(char*)file Line:(int)line;
- (void)My_addObjectsFromArray:(NSArray*)objs File:(char*)file Line:(int)line;
- (void)My_insertObject:(id)anObject atIndex:(NSInteger)index File:(char*)file Line:(int)line;
-(int)My_length_File:(char*)file Line:(int)line;

-(void)My_setString:(NSString*)str File:(char*)file Line:(int)line;


-(void)performBlock:(void (^)(void))block Delay:(float)delay;

@end


NSString *NSStringFromOBJPointer(id obj);
NSString *NSStringFromInt(NSInteger num);
NSString *NSStringFromFloat(float num);
NSString *NSStringFromNumber(id obj);
